export let fileDaoChuUtils = (fileBlob, fileNameStr) => {
  const blob = new Blob([fileBlob]); //返回一个新的blob对象
  let fileName = fileNameStr; //下载文件名
  const downLoadElement = document.createElement("a"); //创建a标签
  downLoadElement.style.display = "none"; //a标签样式为隐藏
  const href = window.URL.createObjectURL(blob); //创建window临时地址
  downLoadElement.href = href; //跳转地址
  downLoadElement.setAttribute("download", fileName);
  document.body.appendChild(downLoadElement); //将指定的dom添加的body之后
  downLoadElement.click(); //点击事件
  document.body.removeChild(downLoadElement); //移除dom
  window.URL.revokeObjectURL(href); //释放url地址
};
// 计算频率分辨率
export const calculateFrequencyResolution = (samplingRate, windowWidth) => {
  // 采样率/取大于的最近二进制（采样率x窗口宽度）
  // 计算采样率与窗口宽度的乘积
  let product = samplingRate * windowWidth;
  // 找到大于等于该乘积的最近的二进制数
  let nearestPowerOfTwo = Math.pow(2, Math.ceil(Math.log2(product)));
  // 计算频率分辨率
  let frequencyResolution = samplingRate / nearestPowerOfTwo;
  return frequencyResolution;
};
